# CC:=gcc
# log:=thirdparty/log/log.h thirdparty/log/log.c

# log_test: test/log_test.c $(log)
# 	-$(CC) $^ -o $@ -Ithirdparty
# 	-./$@
# 	-rm $@

# app_common:= app/app_common.h app/app_common.c
# app_common_test: test/app_common_test.c $(app_common) $(log) 
# 	-$(CC) $^ -o $@ -Ithirdparty -Iapp
# 	-./$@
# 	-rm $@

# app_buffer:= app/app_buffer.h app/app_buffer.c
# app_buffer_test: test/app_buffer_test.c $(app_buffer) $(log) 
# 	-$(CC) $^ -o $@ -Ithirdparty -Iapp
# 	-./$@
# 	-rm $@

# json:=thirdparty/json/cJSON.h thirdparty/json/cJSON.c

# cjson_test: test/cjson_test.c $(log) $(json)
# 	-$(CC) $^ -o $@ -Ithirdparty
# 	-./$@
# 	-rm $@
CC:=gcc

CFLAGS += -Wall -Wextra

CFLAGS += -I.
CFLAGS += -Ithirdparty
CFLAGS += -Iapp

LDLIBS += -lpaho-mqtt3c

SRC += $(shell find app -name "*.c"	-type f)
SRC += $(shell find thirdparty -name "*.c"	-type f)

OBJ := $(SRC:.c=.o)

%.o: %.c
	@-$(CC) $(CFLAGS) -c $^ -o $@

%_test: test/%_test.o $(OBJ)
	@-$(CC) $(CFLAGS) $^ -o $@ $(LDLIBS)
	@-./$@
	@-rm $@ $^

#gcc -Ixxx 为gcc指定include目录